package com.shujia.sql

import org.apache.spark.sql.SparkSession

object Demo9SparkOnHive {
  def main(args: Array[String]): Unit = {
    val sparkSession: SparkSession = SparkSession.builder()
      .master("local")
      .appName("spark读取hive数据")
      .enableHiveSupport()
      .config("spark.sql.shuffle.partitions", 1)
      .getOrCreate()

    import sparkSession.implicits._
    import org.apache.spark.sql.functions._

    sparkSession.sql("use bigdata29")

    sparkSession.sql("select clazz,count(1) as counts from students group by clazz").show()
  }
}
